<?php
function lilina_schedulerapi_get($args)
{
    extract ($args);
    if(!xarSecurityCheck('OverviewLilina')) return;
    $links = xarModAPIFunc('lilina',
                           'user',
                           'getall');

    while (list(, $link) = each($links)) {
        $feeds = xarModAPIFunc('lilina',
                              'user',
                              'process',
                              array('feedfile' => $link['url']));

        if (!isset($feeds['warning'])){
            $linkid = $link['id'];
            $chantitle = $feeds['chantitle'];
            $chanlink = $feeds['chanlink'];
            $content = $feeds['feedcontent'];

            $ico = '';

            foreach ($content as $feed => $feedcontent){
            //$test = var_export($feedcontent, true); echo "<pre>$test</pre>"; return;
                $item_id = md5($feedcontent['link']);  
                if ($feedcontent['date'] == 0){
                    $feedcontent['date'] = time();
                }
                if ($feedcontent['date'] > time()){
                    $feedcontent['date'] = time();
                }
                if(!xarModAPIFunc('lilina',
                                  'user',
                                  'update_story',
                                  array('title'     => $feedcontent['title'],
                                        'summary'   => $feedcontent['description'],
                                        'link'      => $feedcontent['link'],
                                        'timestamp' => $feedcontent['date'],
                                        'ctitle'    => $chantitle,
                                        'curl'      => $chanlink,
                                        'cfavicon'  => $ico,
                                        'linkid'    => $linkid,
                                        'unique'    => $item_id,
                                        'keyword'   => $link['keyword']))) return;
            }
        }
    }
    return true;
}
?>